package com.kooison.idevice4u.database;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable
public class EmailLog {

	public static enum STATUS {
		AVAILABLE, NOT_AVAILABLE
	}

	public static enum CHANNEL {
		ONLINE, RETAIL
	}
	
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key id;

	@Persistent
	private String email;

	@Persistent
	private String product;

	@Persistent
	private String region;

	@Persistent
	private String lastModified;

	@Persistent
	private int sentMailCount;

	@Persistent
	private boolean isEnabled;

	@Persistent
	private String productStatus;
	
	@Persistent
	private String channel;

	public int getSentMailCount() {
		return sentMailCount;
	}

	public void setSentMailCount(int sentMailCount) {
		this.sentMailCount = sentMailCount;
	}

	public EmailLog(String id, String email, String product, String region, String lastModified, STATUS status, CHANNEL channel) {
		// this.id = id;
		this.email = email;
		this.product = product;
		this.region = region;
		this.lastModified = lastModified;
		this.productStatus = status != null ? status.toString() : null;
		this.channel = channel != null ? channel.toString() : null;
		this.isEnabled = true;
	}
	
	public EmailLog(String id, String email, String product, String region, String lastModified, STATUS status) {
		// this.id = id;
		this.email = email;
		this.product = product;
		this.region = region;
		this.lastModified = lastModified;
		this.productStatus = status != null ? status.toString() : null;
		this.channel = CHANNEL.ONLINE.toString();
		this.isEnabled = true;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getProduct() {
		return product;
	}

	public void setProduct(String product) {
		this.product = product;
	}

	public String getRegion() {
		return region;
	}

	public void setRegion(String region) {
		this.region = region;
	}

	public String getLastModified() {
		return lastModified;
	}

	public void setLastModified(String lastModified) {
		this.lastModified = lastModified;
	}

	public boolean isEnabled() {
		return isEnabled;
	}

	public void setEnabled(boolean isEnabled) {
		this.isEnabled = isEnabled;
	}

	public String getProductStatus() {
		return productStatus;
	}

	public void setProductStatus(String poductStatus) {
		this.productStatus = poductStatus;
	}

	public Key getId() {
		return id;
	}

	public void setId(Key id) {
		this.id = id;
	}

	public String getChannel() {
		return channel;
	}

	public void setChannel(String channel) {
		this.channel = channel;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("EmailLog [channel=").append(channel).append(", email=").append(email).append(", id=").append(id).append(
				", isEnabled=").append(isEnabled).append(", lastModified=").append(lastModified).append(", product=").append(
				product).append(", productStatus=").append(productStatus).append(", region=").append(region).append(
				", sentMailCount=").append(sentMailCount).append("]");
		return builder.toString();
	}

}
